/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pgentity.pool;

import java.util.Arrays;

/**
 *
 * @author Salm
 */
public class Identifier {
    final Object[] params;
    private final int hash;

    private Identifier(Object[] params) {
        this.params = params;
        this.hash = Arrays.hashCode(params);
    }

    static Identifier get(Object... pars) {
        return new Identifier(pars);
    }

    public <E> E param(int index, Class<E> clazz) {
        return clazz.cast(params[index]);
    }

    public int size() {
        return params.length;
    }

    @Override
    public int hashCode() {
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Identifier other = (Identifier) obj;
        if (!Arrays.deepEquals(this.params, other.params)) {
            return false;
        }
        return true;
    }
    
}
